﻿namespace FiftyOne.Foundation.Mobile.Detection.Wurfl.Handlers
{
    using FiftyOne.Foundation.Mobile.Detection.Wurfl;
    using System;

    internal class ChromeHandler : VersionHandler
    {
        private const string DEFAULT_DEVICE = "google_chrome";
        private static readonly string PATTERN = @"(?<=Chrome/)[\d+.]+";

        public ChromeHandler() : base(PATTERN)
        {
        }

        protected internal override bool CanHandle(string userAgent)
        {
            return userAgent.Contains("Chrome");
        }

        internal override DeviceInfo DefaultDevice
        {
            get
            {
                DeviceInfo deviceInfoFromID = Provider.Instance.GetDeviceInfoFromID("google_chrome");
                if (deviceInfoFromID != null)
                {
                    return deviceInfoFromID;
                }
                return base.DefaultDevice;
            }
        }
    }
}

